# @Time    : 2018/6/6 11:02
# @Author  : Jame

from db import db_handler
from conf import setting
import os,random


class BasePeople:

    @classmethod
    def select(cls, name):
        return db_handler.select(name)

    # 对象的绑定方法
    def save(self):
        db_handler.save(self)


    # 所有用户修改自己的密码
    def modify_password(self, password):
        self.password = password
        self.save()



class Consumer(BasePeople):
    def __init__(self):
        #self.status=0 #0 false表示没有登陆，1 true 表示已经登陆
        self.balance = 0
        self.capacity=random.randint(1,50) #容量为50


    def register(self,name,password):
        self.name=name
        self.password=password
        self.home=os.path.join(setting.CONSUMER_DIR,name) #用户家目录：db/名字为家目录及用户个人文件存储地址
        self.tmp=os.path.join(setting.CONSUMER_DIR,name) #切换的临时目录
        self.save()





class Admin(BasePeople):
    def __init__(self,name,password):
        pass


